<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: register.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."register.php";
include LOCALE.LOCALESET."user_fields.php";

$sjekk=$_GET['sjekk'];
if($sjekk=="ja"){
	$avloserid=$_POST['ud_avloserid'];
	$utgaar=$_POST['utgaar'];
	$tattoppaar=$_POST['tattoppaar'];
	$selected=implode(',',$_POST['oppkjoring_klasse']); 
	$klasse=implode(',',$_POST['oppkjoring']); 

	$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
	mysql_select_db($GLOBALS['db_name'], $db);  

	$query = "UPDATE forerkort SET klasse='$klasse', tattoppaar='$tattoppaar', utgaar='$utgaar', oppkjoring_klasse='$selected' WHERE avloserid='$avloserid'";
	mysql_query($query);
	mysql_query($query);
}

$query="SELECT klasse FROM oppkjoring";
$result=mysql_query($query);

$options="";

while ($row=mysql_fetch_array($result)) {
    $klasse=$row["klasse"];
    $options.="<OPTION VALUE=\"$klasse\">".$klasse;
}

$avloserid=$_GET['avloserid'];
$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
mysql_select_db($GLOBALS['db_name'], $db); 

$query=" SELECT * FROM forerkort WHERE avloserid='$avloserid'";
$result=mysql_query($query);
$num=mysql_numrows($result);

$avloserid=mysql_result($result,$i,"avloserid");
$tattoppaar=mysql_result($result,$i,"tattoppaar");
$klassen=mysql_result($result,$i,"klasse");
$utgaar=mysql_result($result,$i,"utgaar");
$oppkjoring_klasse=mysql_result($result,$i,"oppkjoring_klasse");

echo "
		<p>&nbsp;&nbsp;<a href='profil.php?avloserid=$avloserid'><b><---  Tilbake til profil</b></a></p>
		<table class='capmain' border='0' cellpadding='0' align='center' width='608px'>
			<tr>	
				<th><font style='text-transform: capitalize;'>Endre Informasjon:</font></th>
			</tr>
		</table>
		<table class='imagetable' table border='1' cellpadding='5' align='center'>
			<form action='forerkort_update_file.php?avloserid=$avloserid&sjekk=ja' method='post'>
			<input type='hidden' name='ud_avloserid' value=$avloserid>
			<tr>
				<th>Registrert Opptaks&aring;r:</th>		<td><input type='text' name='tattoppaar' value=$tattoppaar /></td>
			</tr>
			<tr>
				<th>Registrert f&oslash;rerkortklasse:</th>
				<td><input type='text' name='klasse' readonly='readonly' style='background-color: #D4D4D4' value=$klassen></td>
			</tr>
			<tr>
				<th>Endre klasser p&aring; FK</th>
				<td> 	
					<SELECT NAME='oppkjoring[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring[]'><OPTION VALUE=0>$options</SELECT>
			</td>
			</tr>
			<tr>
				<th>Registrert Utg&aring;ende dato:</th><td><input type='text' name='utgaar' value=$utgaar></td>
			<tr>
			</tr>
			<tr>
				<th>Registrerte oppkj&oslash;ringer:</th>
				<td><input type='text' name='' readonly='readonly' style='background-color: #D4D4D4' 
				value=".$oppkjoring_klasse."></td>
			</tr>
				<th>Legg til oppkj&oslash;ring:</th>
				<td> 
					<SELECT NAME='oppkjoring_klasse[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring_klasse[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring_klasse[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring_klasse[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring_klasse[]'><OPTION VALUE=0>$options</SELECT>
					<SELECT NAME='oppkjoring_klasse[]'><OPTION VALUE=0>$options</SELECT>
				</td>
			</tr>
			<tr>
				<th><input type='Submit' value='Lagre'></th><td></td>
			</tr>
				</form>
		</table><br></br>
";

require_once THEMES."templates/footer.php";
?>